package org.jeecg.modules.collectarticles.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.UnsupportedEncodingException;

/**
 * @author zhy
 */
@Data
public class CollectsVO {
    private String id;
    private String articleTitle;
    private String articleId;
    private String articleAuthor;
    private String articleColumn;
    /**创建时间*/
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @ApiModelProperty(value = "创建时间")
    private java.util.Date createTime;
    /**是否推荐到首页*/
    @Excel(name = "是否推荐到首页", width = 15, dicCode = "is_homepage")
    @Dict(dicCode = "is_homepage")
    @ApiModelProperty(value = "是否推荐到首页")
    private java.lang.Integer isHomepage;
    /**图片*/
    @Excel(name = "图片", width = 15)
    @TableField(exist = false)
    private java.lang.String articleImageString;

    private byte[] articleImage;

    public byte[] getArticleImage(){
        if(articleImageString==null){
            return null;
        }
        try {
            return articleImageString.getBytes("UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return null;
    }

    public String getArticleImageString(){
        if(articleImage==null || articleImage.length==0){
            return "";
        }
        try {
            return new String(articleImage,"UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return "";
    }
    /**类型*/
    @ApiModelProperty(value = "类型，0是知识，1是文章")
    private int itemType = 0;
}
